/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "信息视图.h"


#include <节点/插座/通用插座.h>
#include <节点/插座/list/list物体插座.h>
#include <节点/插座/C_数值插座.h>
#include <节点/插座/C_单值矢量插座.h>
#include "节点/socket_utils.h"
#include "节点/编译声明代码.h"
#include "节点/节点树.h"

#include <物理/物理.h>

#include <Context/数据创建销毁.h>
#include <Context/当前默认操作数据.h>


static std::vector<S_Props> g调试属性_F32;


static void f_JIT_控制台输出(const void* val, E_值类型 type, const void* node) {
	//std::cout << *((std::string*)str) << std::endl;
	//std::cout << "节点:" + socket->f_getLinkOutSocket()->f_getNode()->f_getName();
	//std::cout << "    插座:" + socket->f_getLinkOutSocket()->f_getName();
	//std::cout << std::endl;
	C_控制台输出节点* outNode = dynamic_cast<C_控制台输出节点*>((C_节点基类*)node);
	if(!val) return;

	auto str = f_prop_Str(outNode->m_字符串);
	str = L"<<" + outNode->m_Name + L">>";
	auto* tree = outNode->f_get所在节点树();
	if (tree) {
		str += L" 节点树:" + tree->m_IDName;
	}

	std::string name = f_WStringToString( str ) + " ========= << ";
	
	switch (type) {
		case E_值类型::e_Type_I8: {
			std::cout << name << "I8:" << int32(*((const int8*)val)) << std::endl;
			break;
		}
		case E_值类型::e_Type_I32: {
			std::cout << name << "I32:" << *((const int32*)val) << std::endl;
			break;
		}
		case E_值类型::e_Type_F32: {
			std::cout << name << "F32:" << *((const float32*)val) << std::endl;
			break;
		}
		case E_值类型::e_Type_UI32: {
			std::cout << name << "UI32:" << *((const uint32*)val) << std::endl;
			break;
		}
		case E_值类型::e_Type_Vec2: {
			auto v = *((const vec2*)val);
			std::cout << name << "vec3:" << " x." << v.x << " y." << v.y << std::endl;
			break;
		}
		case E_值类型::e_Type_Vec3: {
			auto v = *((const vec3*)val);
			std::cout << name << "vec3:" << " x." << v.x << " y." << v.y << " z." << v.z << std::endl;
			break;
		}
		case E_值类型::e_Type_Vec4: {
			auto v = *((const vec3*)val);
			std::cout << name << "vec4 << " << " x: " << v.x << " y: " << v.y << " z: " << v.z << " w: " << v.z << std::endl;
			break;
		}
		case E_值类型::e_Type_iVec2: {
			auto v = *((const ivec2*)val);
			std::cout << name << "ivec2:" << " x." << v.x << " y." << v.y << std::endl;
			break;
		}
		case E_值类型::e_Type_iVec3: {
			auto v = *((const ivec3*)val);
			std::cout << name << "ivec3:" << " x." << v.x << " y." << v.y << " z." << v.z << std::endl;
			break;
		}
		case E_值类型::e_Type_F32_1D: {
			const S_F32Array* f32s = (const S_F32Array*)val;
			
			std::cout << " --------------- " << name << "::" << f32s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < f32s->count; ++i) {
				std::cout << "	[f32]: id = " << i << " : " << f32s->ptr_userData[i] << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_I8_1D: {
			const S_I8Array* i8s = (const S_I8Array*)val;

			std::cout << " --------------- " << name << "::" << i8s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < i8s->count; ++i) {
				std::cout << "	[i8]: id = " << i << " : " << int32(i8s->ptr_userData[i]) << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_I32_1D: {
			const S_I32Array* i32s = (const S_I32Array*)val;

			std::cout << " --------------- " << name << "::" << i32s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < i32s->count; ++i) {
				std::cout << "	[i32]: id = " << i << " : " << i32s->ptr_userData[i] << std::endl;
			}
			break;
		}

		case E_值类型::e_Type_UI32_1D: {
			const S_I32Array* ui32s = (const S_I32Array*)val;

			std::cout << " --------------- " << name << "::" << ui32s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < ui32s->count; ++i) {
				std::cout << "	[ui32]: id = " << i << " : " << ui32s->ptr_userData[i] << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_UI32_2D: {
			const S_UI32Array2D* ui32_2ds = (const S_UI32Array2D*)val;

			std::cout << " --------------- " << name << "::" << ui32_2ds->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < ui32_2ds->count; ++i) {
				auto& v = ui32_2ds->ptr_userData[i];
				std::cout << "	UI32_1D数量:" << v->count << std::endl;
				for (uint32 j = 0; j < v->count; ++j) {
					auto& 数组 = v->ptr_userData[j];
					std::cout << "		[ ui32 ]:" << 数组 << std::endl;
				}
			}
			break;
		}

		case E_值类型::e_Type_iVec2_1D: {
			const S_iVec2Array* ivec2s = (const S_iVec2Array*)val;

			std::cout << " --------------- " << name << "::" << ivec2s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < ivec2s->count; ++i) {
				auto& v = ivec2s->ptr_userData[i];
				std::cout << "	[ivec2]:" << " x." << v.x << " y." << v.y << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_iVec3_1D: {
			const S_iVec3Array* ivec3s = (const S_iVec3Array*)val;

			std::cout << " --------------- " << name << "::" << ivec3s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < ivec3s->count; ++i) {
				auto& v = ivec3s->ptr_userData[i];
				std::cout << "	[ivec3]:" << " x." << v.x << " y." << v.y << " z." << v.z << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_iVec3_2D: {
			const S_iVec3Array2D* a = (const S_iVec3Array2D*)val;

			std::cout << " --------------- " << name << "::" << a->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < a->count; ++i) {
				auto& v = a->ptr_userData[i];
				std::cout << "	V3_1D数量:" << v->count << std::endl;
				for (uint32 j = 0; j < v->count; ++j) {
					auto& v3数组 = v->ptr_userData[j];
					std::cout << "		[ivec3]:" << " x." << v3数组.x << " y." << v3数组.y << " z." << v3数组.z << std::endl;
				}
			}
			break;
		}
		case E_值类型::e_Type_Vec3_1D: {
			const S_Vec3Array* vec3s = (const S_Vec3Array*)val;

			std::cout << " --------------- " << name << "::" << vec3s->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < vec3s->count; ++i) {
				auto& v = vec3s->ptr_userData[i];
				std::cout << "	[vec3]:" << " x." << v.x << " y." << v.y << " z." << v.z << std::endl;
			}
			break;
		}
		case E_值类型::e_Type_Vec3_2D: {
			const S_Vec3Array2D* a = (const S_Vec3Array2D*)val;
			if(!a) {
				std::cout << " --------------- Vec3 1D 对象为空 --------------- " << std::endl;
				break;
			}
			std::cout << " --------------- " << name << "::" << a->count << " --------------- " << std::endl;
			for (uint32 i = 0; i < a->count; ++i) {
				auto& v = a->ptr_userData[i];
				std::cout << "	V3_1D数量:" << v->count << std::endl;
				for (uint32 j = 0; j < v->count; ++j) {
					auto& v3数组 = v->ptr_userData[j];
					std::cout << "		[vec3]:" << " x." << v3数组.x << " y." << v3数组.y << " z." << v3数组.z << std::endl;
				}
			}
			break;
		}
		case E_值类型::e_Type_多边形边: {
			const S_边* a = (const S_边*)val;
			std::cout << " --------------- 边 " << name << "::" << a << " --------------- " << std::endl;

			break;
		}
		case E_值类型::e_Type_多边形边1D: {
			const S_边Array* a = (const S_边Array*)val;
			std::cout << " --------------- 边1D " << name << "::" << a->count << " --------------- " << std::endl;
			
			break;
		}
		case E_值类型::e_Type_多边形元素: {
			const S_多边形元素* a = (const S_多边形元素*)val;

			std::cout << " --------------- 多边形元素 " << name << "::" << a->count << " --------------- " << std::endl;
			//for (uint32 i = 0; i < a->count; ++i) {
			//	auto& v = a->ptr_userData[i];
			//	std::cout << "	V3_1D数量:" << v->count << std::endl;
			//	for (uint32 j = 0; j < v->count; ++j) {
			//		auto& v3数组 = v->ptr_userData[j];
			//		std::cout << "		[vec3]:" << " x." << v3数组.x << " y." << v3数组.y << " z." << v3数组.z << std::endl;
			//	}
			//}
			break;
		}
		case E_值类型::e_Type_多边形元素1D: {
			const S_多边形元素Array* a = (const S_多边形元素Array*)val;

			std::cout << " --------------- 多边形元素1D " << name << "::" << a->count << " --------------- " << std::endl;
			//for (uint32 i = 0; i < a->count; ++i) {
			//	auto& v = a->ptr_userData[i];
			//	std::cout << "	V3_1D数量:" << v->count << std::endl;
			//	for (uint32 j = 0; j < v->count; ++j) {
			//		auto& v3数组 = v->ptr_userData[j];
			//		std::cout << "		[vec3]:" << " x." << v3数组.x << " y." << v3数组.y << " z." << v3数组.z << std::endl;
			//	}
			//}
			break;
		}
		default:
			return;
			break;
	}

}


void f_node_所有调试类节点JIT初始化() {
	f_代码构建_添加JIT初始化函数指针(DEF_S(f_JIT_控制台输出), DEF_S(float32), "const void* val, E_值类型 type, const void* str", f_JIT_控制台输出);

}






C_调试输出节点::C_调试输出节点(S_设备环境& ctx) : C_节点基类(DEF_调试输出节点) {
	C_插座基类* socket;
	DEF_创建引用插座_I(L"源1");
	f_get输入插座(1)->f_set多输入();
}

C_调试输出节点::~C_调试输出节点() {
	
}

bool C_调试输出节点::f_update() {
	auto* socket1 = f_get输入插座(1);
	uint32 num = socket1->f_getLinkNum();

	m_Props.clear();

	for (uint32 i = 0; i < num; ++i) {
		S_Props 当前属性;
		if (i >= g调试属性_F32.size()) {
			当前属性 = f_alloc_NoneProp();
			g调试属性_F32.push_back(当前属性);
		}
		else {
			当前属性 = g调试属性_F32[i];
		}

		当前属性.m_Type = socket1->f_get接入的数据类型();
		switch (当前属性.m_Type) {
		case E_值类型::e_Type_F32: {
			当前属性.m_Value = (S_结构对象指针)socket1->f_getLinkOutSocket(i)->f_getData(0);
			break;
		}
		default:
			break;
		}

		当前属性.m_私有 = true;
		if (当前属性.m_UI->m_部件) {
			当前属性.m_UI->m_Set(当前属性);
		}
		m_Props.push_back(当前属性);
	}

	return false;
	

	auto& inData = *DEF_引用插座数据(f_get输入插座(1), 0);

	switch (inData.m_Type) {
		case E_值类型::e_插座Type_Rect32f_Array1D:
			{
				auto& data = *((std::vector<S_Rect2Df>*)inData.m_Data);
				std::cout << "Rect:" << data.size()<<std::endl;
			}
			
			break;

		case E_值类型::e_Type_Object_Array1D:
			{
				auto& data = *((std::vector<S_物体*>*)inData.m_Data);
				std::cout << "物体数量:" << data.size() << std::endl;
				for (auto& e : data) {
					//std::cout << "	ID:" << e->m_ID << " name:" << e->m_Name << " type:"<< e->m_Type << std::endl;
				}
			}
			break;

		case E_值类型::e_插座Type_通用取:
			
			f_输出数据(inData.m_Type, inData.m_Data);
			break;

		default:
			break;
	}
	return false;
}

C_插座基类* C_调试输出节点::f_动态添加插座(E_插座方向 方向) {
	C_插座基类* socket = nullptr;
	return socket;

	E_数据赋值方式 插座操作方式;
	switch (方向)
	{
	case e_插座Type_输入: {
		DEF_创建引用插座_I(L"源1");

		插座操作方式 = E_数据赋值方式::e_赋值_添加;
		break;
	}
	case e_插座Type_输出: {

		插座操作方式 = E_数据赋值方式::e_赋值_添加;
		break;
	}
	//default:
	//	return { nullptr, E_数据赋值方式::e_赋值_None };
	}

	f_set是否要更新(true);
	//return { socket, 插座操作方式 };
}

void C_调试输出节点::f_输出数据(E_值类型 type, void* 数据) {
	switch (type) {
		case E_值类型::e_插座Type_Rect32f_Array1D:
		{
			auto& data = *((std::vector<S_Rect2Df>*)数据);
			std::cout << "Rect:" << data.size() << std::endl;
		}
		break;
		default:
			break;
	}

}

C_节点基类* f_node_创建信息输出节点(S_设备环境& ctx, C_节点树* 子节点树) {
	return new C_调试输出节点(ctx);
}

C_节点基类* f_node_载入信息输出节点(S_设备环境& ctx, FILE* f) {
	C_调试输出节点* node = new C_调试输出节点(ctx);
	return node;
}

void f_node_保存信息输出节点(C_节点基类* n, FILE* f) {
	C_几何预览节点* node = dynamic_cast<C_几何预览节点*>(n);
}











C_几何预览节点::C_几何预览节点(S_设备环境& ctx) : C_节点基类("几何预览节点") {
	m_Name = L"几何预览节点";
	m_Ob = nullptr;
	m_Ctx = ctx;


	C_插座基类* socket;
	DEF_创建引用插座_I(L"几何数据");


	DEF_创建网格插座_O(L"Mesh");


	f_get输入插座(1)->f_set多输入();
}

C_几何预览节点::~C_几何预览节点() {

}

bool C_几何预览节点::f_update() {
	uint16 输入数量 = f_get输入插座(1)->f_getLinkNum();
	m_值类型.resize(输入数量 );
	

	if (!m_Ob) {
		m_Ob = f_node_网格节点创建物体数据(m_Ctx);
		m_Ob->m_可拾取 = false;
	}

	if (输入数量) {
		m_Ob->m_渲染 = true;
	}
	else {
		m_Ob->m_渲染 = false;
	}

	auto* outMesh = DEF_网格插座数据(f_get输出插座(1), 0);

	if (nullptr == outMesh) {
		outMesh = f_surface_创建网格对象(nullptr, m_Ctx, E_网格数据枚举::e_Mesh_VULKAN);
		f_get输出插座(1)->f_setData(outMesh);
	}


	for (uint16 j = 0; j < 输入数量; ++j) {
		S_Mesh* mesh;
		if (j < m_Meshs.size()) {
			mesh = m_Meshs[j];
			f_surface_清空索引数据(mesh);
		}
		else {
			mesh = f_surface_创建网格对象(nullptr, m_Ctx, E_网格数据枚举::e_Mesh_VULKAN);
			m_Meshs.push_back(mesh);
		}


		auto& 输入数据 = *DEF_引用插座数据(f_get输入插座(1), j);
		m_值类型[j] = 输入数据.m_Type;

		switch (输入数据.m_Type) {
		case E_值类型::e_Type_Vec2: {
			//f_surface_填充顶点数据(mesh, { *DEF_引用转VEC3(输入数据.m_Data) });
			break;
		}

		case E_值类型::e_Type_Vec3: {
			*mesh->m_顶点配置Flags = E_顶点组合标志::e_坐标;
			f_surface_fill顶点数据(mesh, { *DEF_引用转Vec3(输入数据) });
			break;
		}
		
		case E_值类型::e_Type_Vec2_Array1D: {
			
			break;
		}

		case E_值类型::e_Type_Cube_Array1D: {
			f_surface_fill顶点数据(mesh, *DEF_引用转Cude_1D(输入数据));
			break;
		}

		case E_值类型::e_插座Type_树路径: {
			auto& tree = *((std::vector<S_八叉树子空间*>*)输入数据.m_Data);
			uint32 num = tree.size();
			auto* data = tree.data();

			std::vector<vec4> vert(num);
			auto* vert_p = vert.data();
			for (uint32 i = 0; i < num; ++i) {
				vert_p[i] = { data[i]->m_坐标.x, data[i]->m_坐标.y, data[i]->m_坐标.z, data[i]->m_域大小 };
			}
			f_surface_fill顶点数据(mesh, vert);
			break;
		}

		case E_值类型::e_插座Type_八叉树: {
			auto* tree = ((S_点距八叉树*)输入数据.m_Data);

			std::vector<vec4> 生成的坐标;
			f_空间划分_解析为坐标(tree, 生成的坐标, true);
			f_surface_fill顶点数据(mesh, 生成的坐标);
			m_值类型[j] = E_值类型::e_Type_Vec4_Array1D;
			break;
		}
		
		case E_值类型::e_Type_Vec3_Array1D: {
			*mesh->m_顶点配置Flags = E_顶点组合标志::e_坐标;
			f_surface_fill顶点数据(mesh, *DEF_引用转Vec3_1D(输入数据));
			m_值类型[j] = E_值类型::e_Type_Vec3_Array1D;
			break;
		}

		case E_值类型::e_插座Type_Line: {
			*mesh->m_顶点配置Flags = E_顶点组合标志::e_坐标;
			f_surface_fill顶点数据(mesh, *DEF_引用转线段(输入数据));
			mesh->m_线宽 = 3.0;
			break;
		}
		case E_值类型::e_插座Type_Line_Array1D: {
			f_surface_fill顶点数据(mesh, *DEF_引用转线段_1D(输入数据));
			mesh->m_线宽 = 3.0;
			break;
		}
		
		case E_值类型::e_Type_Vec4_Array1D: 
		case E_值类型::e_Type_VecSphere_1D: {
			f_surface_fill顶点数据(mesh, *DEF_引用转VecSphere_1D(输入数据));
			m_值类型[j] = E_值类型::e_Type_Vec4_Array1D;
			mesh->m_线宽 = 1.0;
			break;
		}
		
		case E_值类型::e_Type_Object: {
			auto* inData = DEF_引用转物体(输入数据);
			f_surface_Copy(mesh, f_ob_fromMesh(inData));
			break;
		}
		case E_值类型::e_Type_Mesh: {
			auto* inData = DEF_引用转MESH(输入数据);
			if(inData) f_surface_Copy(mesh, inData);
			break;
		}
			
		case E_值类型::e_Type_Mesh_1D: {
			auto& inData = *DEF_引用转MESH_1D(输入数据);
			if(inData.size()) f_surface_Copy(mesh, inData[0]);
			break;
		}

		case E_值类型::e_插座Type_物理体_Array1D: {
			m_值类型[j] = E_值类型::e_Type_Vec3_Array1D;
			auto& inData = *DEF_引用转物理体_1D(输入数据);

			std::vector<vec3> newPoint;
			for (auto& e : inData) {
				S_体素* vo = f_Phy_get发射源体素(e);
				newPoint.insert(newPoint.end(), vo->m_坐标.begin(), vo->m_坐标.end());
			}
			f_surface_fill顶点数据(mesh, newPoint);
			break;
		}
		case E_值类型::e_Type_ParticleSystem: {
			m_值类型[j] = E_值类型::e_Type_Vec3_Array1D;
			auto& inData = *DEF_引用转粒子系统(输入数据);

			f_surface_fill顶点数据(mesh, inData.m_粒子->m_Loc);
			break;
		}
		
		case E_值类型::e_Type_骨架: {
			S_骨架* 骨骼 = DEF_引用转骨架(输入数据);

			std::vector<vec3> vs;
			for (uint32 i = 0; i < 骨骼->m_IK数量; ++i) {
				S_骨骼IK* ik = 骨骼->m_IK[i];
				

				vec4 q = f_ob_计算IK旋转向量(ik);

				vec3 v = f_ob_计算骨骼IK中点(ik);
				vs.push_back(v);

				vec3 s = {};
				if(ik->m_始端) s = f_ob_计算骨骼IK点(ik->m_始端, false);
				//v = f_graph_quat变换坐标(q, v);
				//vs.push_back(v);

				q = f_graph_从轴向角度计算四元数({ q.x, q.y, q.z }, q.w);
				s = f_graph_quat变换坐标(q, f_ob_计算骨骼IK点(ik->m_末端, true) - s);
				vs.push_back(v + s);
			}
			
			f_surface_fill顶点数据(mesh, vs);
			break;
		}

		default:
			f_surface_清空顶点数据(mesh);
		}
	}





	uint8 num = m_Meshs.size();
	f_ob_set数据槽数量(m_Ob, num);
	for (uint16 i = 0; i < 输入数量; ++i) {
		f_ob_set数据(m_Ob, m_Meshs[i], i);
		//if (m_Ob->m_Data[i] == nullptr) {
		//	m_Ob->f_setData(f_surface_创建网格对象(E_网格数据枚举::e_Mesh_VULKAN), i);
		//}
		//f_surface_创建实例((S_Mesh*)m_Ob->m_Data[i], m_Meshs[i]);

		//S_Core::g_VecSphere材质
		switch (m_值类型[i])
		{
		case E_值类型::e_插座Type_八叉树:
		case E_值类型::e_插座Type_树路径: {
			//f_ob_set材质(m_Ob, S_Core::g_体素BOX材质, i);
			break;
		}

		
		case E_值类型::e_Type_Vec3:
		case E_值类型::e_Type_Vec3_Array1D: {
			f_ob_set材质(m_Ob, f_NodeCtx_get单色点材质(), i);
			break;
		}

		case E_值类型::e_Type_Vec4_Array1D:
		case E_值类型::e_Type_VecSphere_1D: {
			f_ob_set材质(m_Ob, f_node_getVecSphere材质(m_Ctx), i);
			break;
		}
		case E_值类型::e_Type_Cube_Array1D:
			//f_ob_set材质(m_Ob, S_Core::g_Cube材质, i);
			break;

		case E_值类型::e_Type_骨架:
		case E_值类型::e_插座Type_Line:
		case E_值类型::e_插座Type_Line_Array1D:
			f_ob_set材质(m_Ob, f_NodeCtx_get单色线段材质(), i);
			break;

		case E_值类型::e_Type_Object: {
			f_ob_set材质(m_Ob, f_NodeCtx_get单色面材质(), i);
			break;
		}
		case E_值类型::e_Type_Mesh_1D:
		case E_值类型::e_Type_Mesh: {
			f_ob_set材质(m_Ob, f_NodeCtx_get单色面材质(), i);
			break;
		}

		
			
		default:
			m_Ob->f_关闭可视通道(i);
			continue;
		}

		m_Ob->f_打开可视通道(i);
	}

	return false;
}

/*S_插座增减方式 C_几何预览节点::f_动态增减插座(E_插座方向 方向) {
	C_插座基类* socket;

	E_数据赋值方式 插座操作方式;

	uint16 num = f_get输入插座Num();
	if (num >= 3 && f_get输入插座(num - 2)->f_isLink() == false) {
		return { nullptr, E_数据赋值方式::e_赋值_None };
	}

	switch (方向)
	{
	case e_插座Type_输入: {
		DEF_创建引用插座_I(L"源1");

		插座操作方式 = E_数据赋值方式::e_赋值_添加;
		break;
	}
	case e_插座Type_输出: {

		插座操作方式 = E_数据赋值方式::e_赋值_添加;
		break;
	}
	default:
		return { nullptr, E_数据赋值方式::e_赋值_None };
	}

	f_set是否要更新(true);
	return { socket, 插座操作方式 };
}*/

S_物体* C_几何预览节点::f_get虚拟体() {
	return nullptr;
}

void C_几何预览节点::f_入回收() {
	f_NodeCtx_get默认场景()->f_remove物体(m_Ob, E_场景物体容器类型::e_集合);
}

void C_几何预览节点::f_回收() {
	f_NodeCtx_get默认场景()->f_add物体({ m_Ob }, E_场景物体容器类型::e_集合);
}

C_节点基类* f_node_载入几何预览节点(S_设备环境& ctx, FILE* f) {
	C_几何预览节点* node = new C_几何预览节点(ctx);

	return node;
}

void f_node_保存几何预览节点(C_节点基类* n, FILE* f) {
	C_几何预览节点* node = dynamic_cast<C_几何预览节点*>(n);

}





C_控制台输出节点::C_控制台输出节点(S_设备环境& ctx) : C_节点基类(DEF_控制台输出节点) {
	m_Name = L"控制台输出";
	m_Ctx = ctx;

	C_插座基类* socket;
	DEF_创建引用插座_I(L"数组");

	m_字符串 = f_alloc_StrProp(nullptr, L"标题");
	m_字符串.m_私有 = true;
}

C_控制台输出节点::~C_控制台输出节点() {
	f_prop_Release(m_字符串);
}

bool C_控制台输出节点::f_update() {
	return false;
}

std::string C_控制台输出节点::DEF_节点编译函数{
	m_Code = "";
	m_ReleaseCode = "";
	std::string name = f_getName();

	f_su_插座类型切换到连入的插座类型(this, E_插座方向::e_插座Type_输入, 1);
	auto* socket1 = f_get输入插座(1);


	m_Code += socket1->f_构建变量代码(0);
	if (socket1->f_isLink()) {
		//m_Code += "节点:" + socket1->f_getLinkOutSocket()->f_getNode()->f_getName();
		//m_Code += "    插座:" + socket1->f_getLinkOutSocket()->f_getName();
		//m_Code += "\n";

		m_Code += DEF_S(f_JIT_控制台输出);
		if (f_代码构建_数组指针(socket1)) {
			m_Code += "(" + socket1->f_getCode(0);
		}
		else {
			m_Code += "(&" + socket1->f_getCode(0);
		}
		m_Code += ", ";

		switch (socket1->m_Type) {
			case E_值类型::e_Type_I8: {
				break;
			}
			case E_值类型::e_Type_I32: {
				break;
			}
			case E_值类型::e_Type_F32: {
				break;
			}
			case E_值类型::e_Type_Vec3: {
				break;
			}
			case E_值类型::e_Type_iVec3: {
				break;
			}
			default:
				break;
		}

		//m_Code += DEF_S(C_插座基类*) + name
		m_Code += DEF_S(E_值类型)"(" + f_整数值转字符串(socket1->m_Type) + ")";

		//m_Code += ", (void*)" + f_整数值转字符串((uint64)str);
		m_Code += ", (const void*)" + f_整数值转字符串((uint64)this);

		m_Code += ");\n";
	}
	

	//outSocket1->f_setCode(name);
	if (m_区域父节点) {
		m_区域父节点->m_Code += m_Code;
		return "";
	}
	return m_Code;
}
void C_控制台输出节点::f_读取(FILE* f) {
	C_节点基类::f_读取(f);

	auto 文件块 = f_file_读取文件块(f);
	if (文件块.m_块类型 == E_节点工程文件块类型::e_工程文件块_节点实例属性) {
		const uint8* 下一次读取数据指针 = 文件块.m_data;
		下一次读取数据指针 = f_prop_Load(m_字符串, 下一次读取数据指针);
	}
	free(文件块.m_data);
}

void C_控制台输出节点::f_写入(FILE* f) {
	C_节点基类::f_写入(f);
	auto 文件块 = f_file_构建文件块信息(E_节点工程文件块类型::e_工程文件块_节点实例属性, S_节点数据::g_文件版本号);
	S_UI8Array* 块 = (S_UI8Array*)f_core_array_new(0, sizeof(uint8));
	
	f_prop_Save(m_字符串, 块);

	文件块.m_data = 块->ptr_userData;
	文件块.m_字节数 = 块->count;
	f_file_保存文件块(f, 文件块);
	f_core_array_free((S_Array*)块);
}

C_节点基类* f_node_创建控制台输出节点(S_设备环境& ctx, C_节点树* 子节点树) {
	return new C_控制台输出节点(ctx);
}
C_节点基类* f_node_加载控制台输出节点(S_设备环境& ctx, FILE* f) {
	C_控制台输出节点* node = new C_控制台输出节点(ctx);
	return node;
}
void f_node_保存控制台输出节点(C_节点基类* n, FILE* f) {
	C_控制台输出节点* node = dynamic_cast<C_控制台输出节点*>(n);
}
